package com.chefu.admin.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chefu.admin.pojo.Area;
import com.chefu.admin.service.AreaService;
import com.chefu.common.pojo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author goodgoodstudy
 * @since 2021-03-30
 */
@RestController
public class AreaController {

    @Autowired
    AreaService areaService;

    /**
     * 根据父级id查询区域列表
     */
    @GetMapping("/area/{pid}")
    public R findByParentId(@PathVariable("pid") Long pid){
        List<Area> areaList = areaService.list(new QueryWrapper<Area>().eq("parent_id", pid));
        return R.ok().data("areaList", areaList);
    }

}

